<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改联盟推广')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-union-edit" th:object="${cmsUnion}">
            <input name="shopId" th:field="*{shopId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品名称：</label>
                <div class="col-sm-8">
                    <input name="shopName" th:field="*{shopName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品主图：</label>
                <div class="col-sm-8">
                    <textarea name="shopImg" class="form-control">[[*{shopImg}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品详情页：</label>
                <div class="col-sm-8">
                    <textarea name="shopIndex" class="form-control">[[*{shopIndex}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">店铺名称：</label>
                <div class="col-sm-8">
                    <input name="homeName" th:field="*{homeName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品价格：</label>
                <div class="col-sm-8">
                    <input name="shopPrice" th:field="*{shopPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品月销量：</label>
                <div class="col-sm-8">
                    <input name="shopSales" th:field="*{shopSales}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">收入比率(%)：</label>
                <div class="col-sm-8">
                    <input name="incomeRatio" th:field="*{incomeRatio}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">佣金：</label>
                <div class="col-sm-8">
                    <input name="commission" th:field="*{commission}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">卖家旺旺：</label>
                <div class="col-sm-8">
                    <input name="wangName" th:field="*{wangName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">淘宝客短链接：</label>
                <div class="col-sm-8">
                    <input name="sortUrl" th:field="*{sortUrl}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">淘宝客链接：</label>
                <div class="col-sm-8">
                    <textarea name="taokeUrl" class="form-control">[[*{taokeUrl}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">优惠券总量：</label>
                <div class="col-sm-8">
                    <input name="couponCount" th:field="*{couponCount}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">优惠券剩余量：</label>
                <div class="col-sm-8">
                    <input name="couponNum" th:field="*{couponNum}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">优惠券面额：</label>
                <div class="col-sm-8">
                    <input name="couponPrice" th:field="*{couponPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">优惠券开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="couponStartTime" th:value="${#dates.format(cmsUnion.couponStartTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">优惠券结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="couponEndTime" th:value="${#dates.format(cmsUnion.couponEndTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">优惠券链接：</label>
                <div class="col-sm-8">
                    <textarea name="couponUrl" class="form-control">[[*{couponUrl}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">优惠券淘口令：</label>
                <div class="col-sm-8">
                    <input name="couponCode" th:field="*{couponCode}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">优惠券短链接：</label>
                <div class="col-sm-8">
                    <input name="couponSortUrl" th:field="*{couponSortUrl}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否为营销计划商品：</label>
                <div class="col-sm-8">
                    <input name="marketIs" th:field="*{marketIs}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">拼团人数：</label>
                <div class="col-sm-8">
                    <input name="groupNum" th:field="*{groupNum}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">拼团价：</label>
                <div class="col-sm-8">
                    <input name="groupPrice" th:field="*{groupPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">团队佣金比例：</label>
                <div class="col-sm-8">
                    <input name="groupCommission" th:field="*{groupCommission}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">拼团开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="groupStartTime" th:value="${#dates.format(cmsUnion.groupStartTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">拼团结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="groupEndTime" th:value="${#dates.format(cmsUnion.groupEndTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品状态：</label>
                <div class="col-sm-8">
                    <input name="visible" th:field="*{visible}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">内容描述：</label>
                <div class="col-sm-8">
                    <input type="hidden" class="form-control" th:field="*{shopContent}">
                    <div class="summernote" id="shopContent"></div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "cms/union";
        $("#form-union-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-union-edit').serialize());
            }
        }

        $("input[name='couponStartTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='couponEndTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='groupStartTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='groupEndTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            $('.summernote').each(function(i) {
                $('#' + this.id).summernote({
                    lang: 'zh-CN',
                    dialogsInBody: true,
                    callbacks: {
                        onChange: function(contents, $edittable) {
                            $("input[name='" + this.id + "']").val(contents);
                        },
                        onImageUpload: function(files) {
                            var obj = this;
                            var data = new FormData();
                            data.append("file", files[0]);
                            $.ajax({
                                type: "post",
                                url: ctx + "common/upload",
                                data: data,
                                cache: false,
                                contentType: false,
                                processData: false,
                                dataType: 'json',
                                success: function(result) {
                                    if (result.code == web_status.SUCCESS) {
                                        $('#' + obj.id).summernote('insertImage', result.url);
                                    } else {
                                        $.modal.alertError(result.msg);
                                    }
                                },
                                error: function(error) {
                                    $.modal.alertWarning("图片上传失败。");
                                }
                            });
                        }
                    }
                });
                var content = $("input[name='" + this.id + "']").val();
                $('#' + this.id).summernote('code', content);
            })
        });
    </script>
</body>
</html>